set more off

eststo clear

foreach city in memphis nashville {

	use "dataset_`city' wave 1", clear
		
	local City = upper(substr("`city'", 1, 1)) + substr("`city'", 2, 50)
	
	if "`city'" == "memphis" local y votestrickland
	if "`city'" == "nashville" local y votebarry
	
	count if !mi(`y') & !mi(ideoself1)
	
	collapse y = `y' (semean) se = `y', by(ideoself1)
	gen ub = y + 1.96*se
	gen lb = y - 1.96*se
	
	#delimit;
	
	gr tw
		(sc y ideoself, col(gs10))
		(rspike ub lb ideoself, col(gs10))
		(lfit y ideoself, col(black) lpat(dash) lwid(medthick))		
		,
			legend(off)
			title(`City')
			plotregion(style(none))
			ytitle("Proportion voting for winner")
			xtitle("Conservatism")
			name(g`city', replace)
			ylab(0(.2)1, angle(horiz))
			yscale(range(0 1))
			xlab(1(1)7)
 			;
			
	#delimit cr
	
}

gr combine gmemphis gnashville, ycommon

gr export "figure 3.eps", replace
shell epstopdf "figure 3.eps"
